package org.darkforest.merchant.controller;

import org.apache.commons.lang3.StringUtils;
import org.darkforest.dao.mapper.GiftReceiveRecordMapper;
import org.darkforest.model.GiftReceiveRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created by Administrator on 2017/4/8.
 */
@Controller
@RequestMapping(value = "giftCode")
public class GiftCodeController {

    @Autowired
    private GiftReceiveRecordMapper giftReceiveRecordMapper;


    @RequestMapping(value = "giftCodeList")
    public ModelAndView giftCodeList(@RequestParam(required = false,defaultValue = "1") int p,String rGiftCode){
        ModelAndView res = new ModelAndView("gift/gift_receive_list");
        GiftReceiveRecord giftReceiveRecord = new GiftReceiveRecord();
        giftReceiveRecord.setStart(p);
        giftReceiveRecord.setrGiftCode(StringUtils.isBlank(rGiftCode)?null:rGiftCode);
        List<GiftReceiveRecord> giftReceiveRecordList = giftReceiveRecordMapper.selectListByCondition(giftReceiveRecord);
        giftReceiveRecord.setResultList(giftReceiveRecordList);
        res.addObject("pageBean",giftReceiveRecord);
        return res;
    }

}
